package djboom.materials.display.elements {
	import flash.events.Event;

	import djboom.materials.state.Font;

	import flash.text.TextFormat;
	import flash.text.AntiAliasType;
	import flash.text.TextFieldAutoSize;

	import org.casalib.display.CasaTextField;
	import org.casalib.display.CasaBitmap;

	import flash.display.BitmapData;

	import org.casalib.display.CasaSprite;

	/**
	 * .
	 * <br>
	 * 
	 * @author DJ BooM 
	 * @since 30.04.2010
	 * 
	 */

	public class SampleInfo extends CasaSprite {

		// ----------------------------------------------------------------------------
		// Константы класса.
		// ----------------------------------------------------------------------------

		private static const TITLE_TFORMAT:TextFormat = new TextFormat(Font.MYRIAD_PRO_COND, 26, 0x004064, null, true);		private static const INFO_TFORMAT:TextFormat = new TextFormat(Font.MYRIAD_PRO_COND, 18, 0x004064, null, true);

		// ----------------------------------------------------------------------------
		// Свойства класса.
		// ----------------------------------------------------------------------------

		private var _bitmapSample:CasaBitmap;
		private var _rhombusShape:Rhombus;
		private var _titleField:CasaTextField;
		private var _descriptionField:CasaTextField;

		// ----------------------------------------------------------------------------
		// Конструктор.
		// ----------------------------------------------------------------------------

		public function SampleInfo(sampleName:String, sampleDescription:String, bitmapData:BitmapData) {
			super();
			
			_bitmapSample = new CasaBitmap(bitmapData);
			_bitmapSample.y = 46;
			addChild(_bitmapSample);
            
			_rhombusShape = new Rhombus(Rhombus.BLUE);
			_rhombusShape.y = 46;
			addChild(_rhombusShape);
            
			_titleField = new CasaTextField();
			_titleField.embedFonts = true;
			_titleField.selectable = false;
			_titleField.multiline = true;
			_titleField.wordWrap = true;
			_titleField.defaultTextFormat = TITLE_TFORMAT;
			_titleField.autoSize = TextFieldAutoSize.LEFT;
			_titleField.antiAliasType = AntiAliasType.ADVANCED;
			_titleField.text = sampleName;
			_titleField.mouseEnabled = false;
			_titleField.thickness = 50;
			_titleField.width = 780;
			_titleField.x = 160;
			addChild(_titleField);
            
			_descriptionField = new CasaTextField();
			_descriptionField.embedFonts = true;
			_descriptionField.selectable = false;
			_descriptionField.multiline = true;
			_descriptionField.wordWrap = true;
			_descriptionField.defaultTextFormat = INFO_TFORMAT;
			_descriptionField.autoSize = TextFieldAutoSize.LEFT;
			_descriptionField.antiAliasType = AntiAliasType.ADVANCED;
			_descriptionField.text = sampleDescription;
			_descriptionField.mouseEnabled = false;
			_descriptionField.thickness = 30;
			_descriptionField.scaleX = 1.2;
			_descriptionField.width = 780 / _descriptionField.scaleX ;
			_descriptionField.x = 160;			_descriptionField.y = 36;
			addChild(_descriptionField);
            
			addEventListener(Event.REMOVED_FROM_STAGE, clearContent);
		}	 

		// ----------------------------------------------------------------------------
		// Методы класса.
		// ----------------------------------------------------------------------------

		private function clearContent(event:Event):void {
			_bitmapSample = null;			_rhombusShape = null;			_titleField = null;			_descriptionField = null;
		}
        
			// ----------------------------------------------------------------------------
			// Публичные методы.
			// ----------------------------------------------------------------------------
			
			// ----------------------------------------------------------------------------
	        // Публичные свойства.
	        // ----------------------------------------------------------------------------
	}
}
